----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/figure_A3_phi_vs_z_manufsectors.log
  log type:  text
 opened on:   2 Nov 2022, 03:10:35

. *-------------------------------------------------------------------------------
. 
. 
. local title "naics_sales_s1_base_woparent"

. clear all

. use "${data}/estimates_sec_`title'.dta", clear

. drop if sector1==sector
(0 observations deleted)

. keep if type=="manuf" 
(315 observations deleted)

. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode sector using "${data}/aggregates_tfp_lp_klems.dta" 
(note: variable sector was str26, now str37 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                        12,350
        from master                         0  (_merge==1)
        from using                     12,350  (_merge==2)

    matched                               162  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(12,350 observations deleted)

. drop _merge

. rename DA D_A 

. replace D_A=. if num_aff<3
(4 real changes made, 4 to missing)

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }
(4 missing values generated)
(4 missing values generated)

. levelsof sector, local(seclist)
`"Basic Metals (24-25)"' `"ChePetPla (19-23)"' `"ElecMach (26-28)"' `"Food (10-12)"' `"TexWood (13-18)"' `"TranspOtherManuf (29-33)"'

. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000015.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_000015.tmp saved

. 
. 
. *Lopping across all manufacturing sectors 
. *----------------------------------------
. foreach selecsec of local seclist {
  2. display "`selecsec'"
  3. 
. use `temp', clear
  4. keep if year==`yy' & sector=="`selecsec'"
  5. sum num_aff
  6. 
. 
. local LHS1 D_`var3'_phi
  7. local LHS2 b_D_`var3'_phi_`grvar0'
  8. local RHS ln_`grvar0'
  9.         
. sum `LHS1' `RHS'  `LHS2'
 10. local ytitle "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}, {&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"
 11. local xtitle "{&Delta}y{sub:n}"
 12. local firm_emb "{&Delta}`=ustrunescape("\u03D5\u0303")'{sub:n}" 
 13. local ctry_emb "{&Delta}`=ustrunescape("\u007A\u0303")'{sub:n}"
 14. 
. reg `LHS1' `RHS' 
 15. mat b = e(b)
 16. mat V = e(V)
 17. global c1: display %-03.2fc round(b[1,1],0.01)
 18. global se1: display %-03.2fc round(sqrt(V[1,1]),0.01)
 19. 
. reg `LHS2' `RHS' 
 20. mat b = e(b)
 21. mat V = e(V)
 22. global c2: display %-03.2fc round(b[1,1],0.01)
 23. global se2: display %-03.2fc round(sqrt(V[1,1]),0.01)
 24. 
. display $c1
 25. display $se1
 26. display $c2
 27. display $se2
 28. 
. global opt1 msymbol(circle_hollow) mlabel(isocode) mlabcolor(red)  msize(medium) mlabsize(small)
 29. global opt2 msymbol(square_hollow) mlabel(isocode) mlabcolor(blue) msize(medium) mlabsize(small)
 30. two (scatter `LHS1' `RHS', sort $opt1  mcolor(red)) (lfit `LHS1' `RHS', lcolor(red)) (line `RHS' `RHS', lcolor(none))  ///
>         (scatter `LHS2' `RHS', sort $opt2  mcolor(blue)) (lfit `LHS2' `RHS', lcolor(blue)) (line `RHS' `RHS', lcolor(none)),  xscale(titlegap(*1)) ylabel(-1.5(0.5)1, format(%5.
> 1f) labsize(medlarge)) xlabel(, format(%5.1f) labsize(medlarge)) ///
>         title("", size(small)) ytitle("`ytitle'", size(medlarge)) xtitle("`xtitle'", size(medlarge)) graphregion(fcolor(white) lcolor(white)) ///
>         legend(order(2 "`firm_emb': $c1 ($se1)" 5 "`ctry_emb': $c2 ($se2)") rows(2) size(medlarge) bplace(se) ring(0) region(lwidth(none))) 
 31. 
. display "`selecsec'"
 32. graph export "${rappendix}/fig_A3_sector_`selecsec'.pdf", replace
 33. 
. }
Basic Metals (24-25)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    56.59259    53.75962          3        167

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2108821    .2802855  -.7914315   .4802361
ln_LP_ppp_.. |         27   -.1352086    .3382051  -.7179848    .388784
b_D_A_phi_~t |         27    .0756735    .2617987  -.3716775   .7175848

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     18.90
       Model |  .879473146         1  .879473146   Prob > F        =    0.0002
    Residual |  1.16308657        25  .046523463   R-squared       =    0.4306
-------------+----------------------------------   Adj R-squared   =    0.4078
       Total |  2.04255971        26  .078559989   Root MSE        =    .21569

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .5438067   .1250746     4.35   0.000     .2862106    .8014027
            _cons |  -.1373547   .0448227    -3.06   0.005    -.2296689   -.0450406
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     13.30
       Model |  .618915614         1  .618915614   Prob > F        =    0.0012
    Residual |  1.16308654        25  .046523462   R-squared       =    0.3473
-------------+----------------------------------   Adj R-squared   =    0.3212
       Total |  1.78200215        26  .068538544   Root MSE        =    .21569

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .4561933   .1250746     3.65   0.001     .1985973    .7137894
            _cons |   .1373547   .0448227     3.06   0.005     .0450406    .2296689
-----------------------------------------------------------------------------------
.54
.13
.46
.13
Basic Metals (24-25)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A3_sector_Basic Metals (24-25).pd
> f written in PDF format)
ChePetPla (19-23)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    113.5185    104.7232         11        321

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.2019566    .2049096  -.6370201   .1318088
ln_LP_ppp_.. |         27   -.3192919    .3993458  -1.057186   .3794154
b_D_A_phi_~t |         27   -.1173353    .3402465  -.6494768   .6822572

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =      9.44
       Model |  .299329653         1  .299329653   Prob > F        =    0.0051
    Residual |  .792357213        25  .031694289   R-squared       =    0.2742
-------------+----------------------------------   Adj R-squared   =    0.2452
       Total |  1.09168687        26  .041987956   Root MSE        =    .17803

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .2686823   .0874288     3.07   0.005     .0886193    .4487454
            _cons |  -.1161685   .0441942    -2.63   0.014    -.2071882   -.0251488
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     69.97
       Model |  2.21760253         1  2.21760253   Prob > F        =    0.0000
    Residual |  .792357192        25  .031694288   R-squared       =    0.7368
-------------+----------------------------------   Adj R-squared   =    0.7262
       Total |  3.00995972        26  .115767682   Root MSE        =    .17803

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .7313177   .0874288     8.36   0.000     .5512546    .9113807
            _cons |   .1161685   .0441942     2.63   0.014     .0251488    .2071882
-----------------------------------------------------------------------------------
.27
.09
.73
.09
ChePetPla (19-23)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A3_sector_ChePetPla (19-23).pdf w
> ritten in PDF format)
ElecMach (26-28)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    111.0741    117.6481          4        406

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         27   -.1322792    .2926072  -.7155507   .4387037
ln_LP_ppp_.. |         27   -.3784576    .4088235  -1.175163   .2597615
b_D_A_phi_~t |         27   -.2461784    .3466208  -.9840143    .309323

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     11.09
       Model |  .683898918         1  .683898918   Prob > F        =    0.0027
    Residual |  1.54219388        25  .061687755   R-squared       =    0.3072
-------------+----------------------------------   Adj R-squared   =    0.2795
       Total |   2.2260928        26  .085618954   Root MSE        =    .24837

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .3967102   .1191453     3.33   0.003     .1513259    .6420946
            _cons |   .0178588   .0657113     0.27   0.788    -.1174761    .1531937
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        27
-------------+----------------------------------   F(1, 25)        =     25.64
       Model |  1.58160119         1  1.58160119   Prob > F        =    0.0000
    Residual |  1.54219393        25  .061687757   R-squared       =    0.5063
-------------+----------------------------------   Adj R-squared   =    0.4866
       Total |  3.12379512        26  .120145966   Root MSE        =    .24837

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .6032898   .1191453     5.06   0.000     .3579054    .8486741
            _cons |  -.0178588   .0657113    -0.27   0.788    -.1531937    .1174761
-----------------------------------------------------------------------------------
.4
.12
.6
.12
ElecMach (26-28)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A3_sector_ElecMach (26-28).pdf wr
> itten in PDF format)
Food (10-12)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    38.77778    32.11438          1        112

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         25   -.2754101    .2167283  -.7440919    .029559
ln_LP_ppp_.. |         27   -.2765508     .361426  -1.024175   .4397315
b_D_A_phi_~t |         25   -.0203397    .2911443  -.7797828   .5034884

      Source |       SS           df       MS      Number of obs   =        25
-------------+----------------------------------   F(1, 23)        =     14.04
       Model |  .427323077         1  .427323077   Prob > F        =    0.0011
    Residual |  .699985067        23  .030434133   R-squared       =    0.3791
-------------+----------------------------------   Adj R-squared   =    0.3521
       Total |  1.12730814        24  .046971173   Root MSE        =    .17445

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .3613893   .0964445     3.75   0.001     .1618786    .5609001
            _cons |  -.1685293   .0450661    -3.74   0.001    -.2617556    -.075303
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        25
-------------+----------------------------------   F(1, 23)        =     43.84
       Model |  1.33437537         1  1.33437537   Prob > F        =    0.0000
    Residual |  .699985056        23  .030434133   R-squared       =    0.6559
-------------+----------------------------------   Adj R-squared   =    0.6410
       Total |  2.03436042        24  .084765018   Root MSE        =    .17445

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .6386107   .0964445     6.62   0.000     .4390999    .8381214
            _cons |   .1685293   .0450661     3.74   0.001      .075303    .2617556
-----------------------------------------------------------------------------------
.36
.1
.64
.1
Food (10-12)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A3_sector_Food (10-12).pdf writte
> n in PDF format)
TexWood (13-18)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    34.48148    29.05084          2         94

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         26   -.1421751    .1838651  -.4470168   .1686504
ln_LP_ppp_.. |         27    -.360487    .4708283  -1.436753   .2591576
b_D_A_phi_~t |         26   -.2189447    .4517402  -1.112869   .4790739

      Source |       SS           df       MS      Number of obs   =        26
-------------+----------------------------------   F(1, 24)        =      3.17
       Model |   .09848713         1   .09848713   Prob > F        =    0.0879
    Residual |   .74667256        24  .031111357   R-squared       =    0.1165
-------------+----------------------------------   Adj R-squared   =    0.0797
       Total |   .84515969        25  .033806388   Root MSE        =    .17638

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .1307227   .0734718     1.78   0.088    -.0209157    .2823611
            _cons |  -.0949686   .0435952    -2.18   0.039    -.1849447   -.0049924
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        26
-------------+----------------------------------   F(1, 24)        =    139.98
       Model |   4.3550577         1   4.3550577   Prob > F        =    0.0000
    Residual |  .746672564        24  .031111357   R-squared       =    0.8536
-------------+----------------------------------   Adj R-squared   =    0.8475
       Total |  5.10173027        25  .204069211   Root MSE        =    .17638

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .8692773   .0734718    11.83   0.000     .7176389    1.020916
            _cons |   .0949686   .0435952     2.18   0.039     .0049924    .1849447
-----------------------------------------------------------------------------------
.13
.07
.87
.07
TexWood (13-18)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A3_sector_TexWood (13-18).pdf wri
> tten in PDF format)
TranspOtherManuf (29-33)
(135 observations deleted)

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     num_aff |         27    52.81481    49.85906          2        179

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
     D_A_phi |         26   -.2914406     .264729  -.8700804   .1429273
ln_LP_ppp_.. |         27   -.6054748    .4278422  -1.467384    .094129
b_D_A_phi_~t |         26   -.3185943    .2884291   -.798924   .3453465

      Source |       SS           df       MS      Number of obs   =        26
-------------+----------------------------------   F(1, 24)        =     34.07
       Model |  1.02795523         1  1.02795523   Prob > F        =    0.0000
    Residual |  .724081007        24  .030170042   R-squared       =    0.5867
-------------+----------------------------------   Adj R-squared   =    0.5695
       Total |  1.75203624        25   .07008145   Root MSE        =     .1737

-----------------------------------------------------------------------------------
          D_A_phi |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .4654616   .0797416     5.84   0.000     .3008831      .63004
            _cons |  -.0074928   .0593863    -0.13   0.901    -.1300601    .1150746
-----------------------------------------------------------------------------------

      Source |       SS           df       MS      Number of obs   =        26
-------------+----------------------------------   F(1, 24)        =     44.94
       Model |  1.35570255         1  1.35570255   Prob > F        =    0.0000
    Residual |  .724081014        24  .030170042   R-squared       =    0.6518
-------------+----------------------------------   Adj R-squared   =    0.6373
       Total |  2.07978357        25  .083191343   Root MSE        =     .1737

-----------------------------------------------------------------------------------
b_D_A_phi_LP_pp~t |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
------------------+----------------------------------------------------------------
ln_LP_ppp_emp_pwt |   .5345384   .0797416     6.70   0.000       .36996    .6991169
            _cons |   .0074928   .0593863     0.13   0.901    -.1150746    .1300601
-----------------------------------------------------------------------------------
.47
.08
.53
.08
TranspOtherManuf (29-33)
(file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/fig_A3_sector_TranspOtherManuf (29-33
> ).pdf written in PDF format)

. 
. 
. 
. 
end of do-file

. do "F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\code\appendix\figure_A4_phi_vs_z_servsectors.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: figure_A4_phi_vs_z_servsectors.do
> Date: October 2022
> 
> Description: Reproduces Figure A4: Dev. accounting: Services sectors.
> 
> *****************************************************************************************/
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. cap log close
